<?php

class segmentoController extends CController{
    
    public $model_name = "tenap/segmento";
    public function __construct($vars) {
        parent::__construct($vars);
        $this->registerVar("component", LINK);
    }
    
    public function index(){
        $this->setPage();
        $this->genTags(CURRENT_MODULE ." ", CURRENT_MODULE);                
        $this->registerVar("item"        , $this->model->paginate($this->page, CURRENT_PAGE, "", "", 0));
        $this->registerVar("comp_action" , 'listar');
        $this->registerVar("show_links"  , '');
    	$this->display("admin/auto/areacliente/page");
    }
    
    public function show(){
        
        $this->setMainVars();
        $this->setPage();
        $this->model->setPage($this->page);
        
        $nome =  GetPlainName($this->item['catnome']);
        if($nome == "residencias") Redirect('tenap/regiao');
        
        $this->tags($this->item);
        $this->genTags($this->item['catnome'], "Segmento ".$this->item['catnome']);
        if($nome == "projetos")$this->registerVar("item", $this->model->segpro_getItem($this->cod));
        else $this->registerVar("item", $this->model->seg_getItem($this->cod));
        $this->registerVar("comp_action" , 'show');
    	$this->display("admin/auto/areacliente/page");
    }
    
}

?>
